import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Test02 {
    public static void main(String[] args) {
        //2.	定义MainApp类，包含main()方法；
        //3.	在main()方法中，创建一个可以存储Student对象的集合对象；
        ArrayList<Student> list=new ArrayList<Student>();
        //4.	创建以下几个Student对象：
        //	学号		姓名		身高
        //	it001	黄渤		1.72
        //	it002	孙红雷	1.78
        //	it003	章子怡	1.64
        //	it004	杨颖		1.68
        //5.	将上面几个对象添加到集合中
        list.add(new Student("it001","黄渤",1.72));
        list.add(new Student("it002","孙红雷",1.78));
        list.add(new Student("it003","章子怡",1.64));
        list.add(new Student("it004","杨颖",1.68));
        System.out.println("6.历集合打印每个对象的属性值；");
        Iterator iterator=list.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }
        System.out.println("7.获取并打印集合大小；");
        System.out.println(list.size());
        System.out.println("8.获取第3个学员对象，并打印其属性值；");
        System.out.println(list.get(2));
        System.out.println("9.除掉第4个学员对象；");
        list.remove(3);
        System.out.println("list = " + list);
        System.out.println("10.再次获取并打印集合大小；");
        System.out.println(list.size());
        System.out.println("//11.将第一个对象替换为以下对象：" + "it005\t撒贝宁\t1.67");
        list.set(0,new Student("it005","撒贝宁",1.67));
        System.out.println("12.遍历集合，打印出身高在1.70以上的学员信息；");
        for(int i=0;i<list.size();i++){
            if(list.get(i).getHeight()>1.70){
                System.out.println(list.get(i));
            }
        }

        System.out.println("13.遍历集合，打印出“孙”姓的学员信息；");
        for(int i=0;i<list.size();i++){
            if(list.get(i).getName().contains("孙")){
                System.out.println(list.get(i));
            }
        }
    }
}
//定义Student类，包含以下属性：
//	学号、姓名、身高
class Student{
    String id;
    String name;
    Double height;

    public Student(String id, String name, Double height) {
        this.id = id;
        this.name = name;
        this.height = height;
    }

    public Student() {
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getHeight() {
        return height;
    }

    public void setHeight(Double height) {
        this.height = height;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", height=" + height +
                '}';
    }
}